package com.bruce.pattern.structural.flyweight;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by bruce on 2018/11/4 21:13
 */
@Slf4j
public class EmployeeFactory {

    private static final ConcurrentHashMap<String, Employee> EMPLOYEE_MAP = new ConcurrentHashMap<>();

    public static Employee getManager(String dept) {
        return EMPLOYEE_MAP.computeIfAbsent(dept, (key) -> {
            log.info("新建manager对象");
            Manager manager = new Manager(key);
            manager.setReportContent("新年快乐");
            return manager;
        });
    }


}
